OPC-UA Embedded Server SDK  2.1.0
File Transfer Functions

Functions

void UAServer_Callback_File_Size (uint32_t node_handle, uintptr_t context)
 
UA_Status_t UAServer_File_Size_result (uintptr_t context, uint64_t size, UA_Status_t result)
 
void UAServer_Callback_File_Open (uint32_t node_handle, uint8_t mode, uintptr_t context)
 
UA_Status_t UAServer_File_Open_result (uintptr_t context, uint32_t file_handle, UA_Status_t result)
 
void UAServer_Callback_File_Close (uint32_t node_handle, uint32_t file_handle, uintptr_t context)
 
UA_Status_t UAServer_File_Close_result (uintptr_t context, UA_Status_t result)
 
void UAServer_Callback_File_Read (uint32_t node_handle, uint32_t file_handle, int32_t length, uintptr_t context)
 
UA_Status_t UAServer_File_Read_result (uintptr_t context, UA_Byte_string_t data, UA_Status_t result)
 
void UAServer_Callback_File_Write (uint32_t node_handle, uint32_t file_handle, UA_Byte_string_t data, uintptr_t context)
 
UA_Status_t UAServer_File_Write_result (uintptr_t context, UA_Status_t result)
 
void UAServer_Callback_File_GetPosition (uint32_t node_handle, uint32_t file_handle, uintptr_t context)
 
UA_Status_t UAServer_File_GetPosition_result (uintptr_t context, uint64_t position, UA_Status_t result)
 
void UAServer_Callback_File_SetPosition (uint32_t node_handle, uint32_t file_handle, uint64_t position, uintptr_t context)
 
UA_Status_t UAServer_File_SetPosition_result (uintptr_t context, UA_Status_t result)
 

Detailed Description

Function Documentation

void UAServer_Callback_File_Size ( uint32_t  node_handle,
uintptr_t  context 
)

Function provided by host to enable file size to be reported

The function UAServer_File_Size_result() must be called within this function body to complete the operation.

Parameters
[in]node_handleThe handle of the FileType node identifying the file in the address space.
[in]contextA handle to the operation context which is passed to the library via UAServer_File_Open_result() to complete the operation.
UA_Status_t UAServer_File_Size_result ( uintptr_t  context,
uint64_t  size,
UA_Status_t  result 
)

Function to complete file size operation

This function must be called within the body of function UAServer_Callback_File_Size() to complete the operation.

Parameters
[in]contextA handle to the operation context received from UAServer_Callback_File_Size().
[in]sizeThe current size of the file in bytes.
[in]result0 Success. Bad_UnexpectedError See Part 4 for a general description. Bad_NotFound See Part 4 for a general description.
Returns
OPC-UA Status Code 0 Success. >0 Failure.
void UAServer_Callback_File_Open ( uint32_t  node_handle,
uint8_t  mode,
uintptr_t  context 
)

Function provided by host to enable files to be opened

Open is used to open a file represented by an Object of FileType. When a client opens a file it gets a file handle that is valid while the session is open. Clients shall use the Close Method to release the handle when they do not need access to the file anymore. Clients can open the same file several times for read. A request to open for writing shall return Bad_NotWritable when the file is already opened. A request to open for reading shall return Bad_NotReadable when the file is already opened for writing.

The function UAServer_File_Open_result() must be called within this function body to complete the operation.

Parameters
[in]node_handleThe handle of the FileType node identifying the file in the address space.
[in]modeIndicates whether the file should be opened only for read operations or for read and write operations and where the initial position is set. The mode is an 8-bit unsigned integer used as bit mask with the structure defined in the following table:

Field Bit Description

Read 0 The file is opened for reading. If this bit is not set the Read Method cannot be executed.

Write 1 The file is opened for writing. If this bit is not set the Write Method cannot be executed.

EraseExisiting 2 This bit can only be set if the file is opened for writing (Write bit is set). The existing content of the file is erased and an empty file is provided.

Append 3 When the Append bit is set the file is opened at end of the file, otherwise at begin of the file. The SetPosition Method can be used to change the position.

Reserved 4:7 Reserved for future use. Shall always be zero..

Parameters
[in]contextA handle to the operation context which is passed to the library via UAServer_File_Open_result() to complete the operation.
UA_Status_t UAServer_File_Open_result ( uintptr_t  context,
uint32_t  file_handle,
UA_Status_t  result 
)

Function to complete file open operation

This function must be called within the body of function UAServer_Callback_File_Open() to complete the operation.

Parameters
[in]contextA handle to the operation context received from UAServer_Callback_File_Open().
[in]file_handleA handle for the file used in other method calls indicating not the file (this is done by the Object of the Method call) but the access request and thus the position in the file. The fileHandle is generated by the server and is unique for the Session. Clients cannot transfer the fileHandle to another Session but need to get a new fileHandle by calling the Open Method.
[in]result0 Success. Bad_NotReadable See Part 4 for a general description. File might be locked and thus not readable. Bad_NotWritable See Part 4 for a general description. Bad_InvalidState See Part 4 for a general description. The file is locked and thus not writable. Bad_InvalidArgument See Part 4 for a general description. Mode setting is invalid. Bad_UnexpectedError See Part 4 for a general description. Bad_NotFound See Part 4 for a general description.
Returns
OPC-UA Status Code 0 Success. >0 Failure.
void UAServer_Callback_File_Close ( uint32_t  node_handle,
uint32_t  file_handle,
uintptr_t  context 
)

Function provided by host to enable files to be closed

Close is used to close a file represented by a FileType. When a client closes a file the handle becomes invalid.

The function UAServer_File_Close_result() must be called within this function body to complete the operation.

Parameters
[in]node_handleThe handle of the FileType node identifying the file in the address space.
[in]file_handleA handle indicating the access request and thus indirectly the position inside the file.
[in]contextA handle to the operation context which is passed to the library via UAServer_File_Close_result() to complete the operation.
UA_Status_t UAServer_File_Close_result ( uintptr_t  context,
UA_Status_t  result 
)

Function to complete file close operation

This function must be called within the body of function UAServer_Callback_File_Close() to complete the operation.

Parameters
[in]contextA handle to the operation context received from UAServer_Callback_File_Close().
[in]result0 Success. Bad_InvalidArgument See Part 4 for a general description. Invalid file handle in call.
Returns
OPC-UA Status Code 0 Success. >0 Failure.
void UAServer_Callback_File_Read ( uint32_t  node_handle,
uint32_t  file_handle,
int32_t  length,
uintptr_t  context 
)

Function provided by host to enable files to be read

Read is used to read a part of the file starting from the current file position. The file position is advanced by the number of bytes read.

The function UAServer_File_Read_result() must be called within this function body to complete the operation.

Parameters
[in]node_handleThe handle of the FileType node identifying the file in the address space.
[in]file_handleA handle indicating the access request and thus indirectly the position inside the file.
[in]lengthDefines the length in byte that should be returned in data, starting from the current position of the file handle. If the end of file is reached only all data till the end of the file are returned. If the specified length is longer than the maximum allowed message size of the communication, only those data fitting into the message size are returned. Only positive values are allowed.
[in]contextA handle to the operation context which is passed to the library via UAServer_File_Read_result() to complete the operation.
UA_Status_t UAServer_File_Read_result ( uintptr_t  context,
UA_Byte_string_t  data,
UA_Status_t  result 
)

Function to complete file read operation

This function must be called within the body of function UAServer_Callback_File_Read() to complete the operation.

Parameters
[in]contextA handle to the operation context received from UAServer_Callback_File_Read().
[in]dataThe data to be read.
[in]result0 Success. Bad_InvalidState See Part 4 for a general description. File was not opened for read access. Bad_InvalidArgument See Part 4 for a general description. Invalid file handle in call or non positive length. Bad_UnexpectedError See Part 4 for a general description.
Returns
OPC-UA Status Code 0 Success. >0 Failure.
void UAServer_Callback_File_Write ( uint32_t  node_handle,
uint32_t  file_handle,
UA_Byte_string_t  data,
uintptr_t  context 
)

Function provided by host to enable files to be written

Write is used to write a part of the file starting from the current file position. The file position is advanced by the number of bytes written.

The function UAServer_File_Write_result() must be called within this function body to complete the operation.

Parameters
[in]node_handleThe handle of the FileType node identifying the file in the address space.
[in]file_handleA handle indicating the access request and thus indirectly the position inside the file.
[in]dataContains the data to be written at the position of the file. It is server-dependent whether the written data are persistently stored if the session is ended without calling the Close Method with the fileHandle.
[in]contextA handle to the operation context which is passed to the library via UAServer_File_Write_result() to complete the operation.
UA_Status_t UAServer_File_Write_result ( uintptr_t  context,
UA_Status_t  result 
)

Function to complete file write operation

This function must be called within the body of function UAServer_Callback_File_Write() to complete the operation.

Parameters
[in]contextA handle to the operation context received from UAServer_Callback_File_Write().
[in]result0 Success. Bad_InvalidArgument See Part 4 for a general description. Invalid file handle in call. Bad_NotWritable See Part 4 for a general description. File might be locked and thus not writable. Bad_InvalidState See Part 4 for a general description. File was not opened for write access.
Returns
OPC-UA Status Code 0 Success. >0 Failure.
void UAServer_Callback_File_GetPosition ( uint32_t  node_handle,
uint32_t  file_handle,
uintptr_t  context 
)

Function provided by host to enable file positions to be read

GetPosition is used to provide the current position of the file handle.

The function UAServer_File_GetPosition_result() must be called within this function body to complete the operation.

Parameters
[in]node_handleThe handle of the FileType node identifying the file in the address space.
[in]file_handleA handle indicating the access request and thus indirectly the position inside the file.
[in]contextA handle to the operation context which is passed to the library via UAServer_File_GetPosition_result() to complete the operation.
UA_Status_t UAServer_File_GetPosition_result ( uintptr_t  context,
uint64_t  position,
UA_Status_t  result 
)

Function to complete file open operation

This function must be called within the body of function UAServer_Callback_File_GetPosition() to complete the operation.

Parameters
[in]contextA handle to the operation context received from UAServer_Callback_File_GetPosition().
[in]positionThe position of the fileHandle in the file. If a Read or Write is called it starts at that position.
[in]result0 Success. Bad_InvalidArgument See Part 4 for a general description. Invalid file handle in call.
Returns
OPC-UA Status Code 0 Success. >0 Failure.
void UAServer_Callback_File_SetPosition ( uint32_t  node_handle,
uint32_t  file_handle,
uint64_t  position,
uintptr_t  context 
)

Function provided by host to enable file positions to be written

SetPosition is used to set the current position of the file handle.

The function UAServer_File_SetPosition_result() must be called within this function body to complete the operation.

Parameters
[in]node_handleThe handle of the FileType node identifying the file in the address space.
[in]file_handleA handle indicating the access request and thus indirectly the position inside the file.
[in]positionThe position to be set for the fileHandle in the file. If a Read or Write is called it starts at that position. If the position is higher than the file size the position is set to the end of the file.
[in]contextA handle to the operation context which is passed to the library via UAServer_File_SetPosition_result() to complete the operation.
UA_Status_t UAServer_File_SetPosition_result ( uintptr_t  context,
UA_Status_t  result 
)

Function to complete file set position operation

This function must be called within the body of function UAServer_Callback_File_SetPosition() to complete the operation.

Parameters
[in]contextA handle to the operation context received from UAServer_Callback_File_SetPosition().
[in]result0 Success. Bad_InvalidArgument See Part 4 for a general description. Invalid file handle in call.
Returns
OPC-UA Status Code 0 Success. >0 Failure.